package net.arvin.model;

import java.util.ArrayList;
import java.util.List;

public class TransfersBill {
	private List<String> cardOrUser;
	private List<String> recieveOrSend;
	private List<String> nickname;
	private List<String> phonenumber;
	private List<String> cardBank;
	private List<String> cardnumber;
	private List<String> money;
	private List<String> time;

	public TransfersBill() {
		this.cardOrUser = new ArrayList<String>();
		this.recieveOrSend = new ArrayList<String>();
		this.nickname = new ArrayList<String>();
		this.phonenumber = new ArrayList<String>();
		this.cardBank = new ArrayList<String>();
		this.cardnumber = new ArrayList<String>();
		this.money = new ArrayList<String>();
		this.time = new ArrayList<String>();
	}

	public TransfersBill(List<String> cardOrUser, List<String> recieveOrSend,
			List<String> nickname, List<String> phonenumber,
			List<String> cardBank, List<String> cardnumber, List<String> money,
			List<String> time) {
		super();
		this.cardOrUser = cardOrUser;
		this.recieveOrSend = recieveOrSend;
		this.nickname = nickname;
		this.phonenumber = phonenumber;
		this.cardBank = cardBank;
		this.cardnumber = cardnumber;
		this.money = money;
		this.time = time;
	}

	public List<String> getCardOrUser() {
		return cardOrUser;
	}

	public void setCardOrUser(List<String> cardOrUser) {
		this.cardOrUser = cardOrUser;
	}

	public List<String> getRecieveOrSend() {
		return recieveOrSend;
	}

	public void setRecieveOrSend(List<String> recieveOrSend) {
		this.recieveOrSend = recieveOrSend;
	}

	public List<String> getNickname() {
		return nickname;
	}

	public void setNickname(List<String> nickname) {
		this.nickname = nickname;
	}

	public List<String> getPhonenumber() {
		return phonenumber;
	}

	public void setPhonenumber(List<String> phonenumber) {
		this.phonenumber = phonenumber;
	}

	public List<String> getCardBank() {
		return cardBank;
	}

	public void setCardBank(List<String> cardBank) {
		this.cardBank = cardBank;
	}

	public List<String> getCardnumber() {
		return cardnumber;
	}

	public void setCardnumber(List<String> cardnumber) {
		this.cardnumber = cardnumber;
	}

	public List<String> getMoney() {
		return money;
	}

	public void setMoney(List<String> money) {
		this.money = money;
	}

	public List<String> getTime() {
		return time;
	}

	public void setTime(List<String> time) {
		this.time = time;
	}

	public TransfersBill softListByTime(TransfersBill bill) {
		TransfersBill bill2 = new TransfersBill();
		Time[] times = new Time[bill.getTime().size()];
		for (int i = 0; i < bill.getTime().size(); i++) {
			Time time = new Time();
			time.toTime(bill.getTime().get(i));
			times[i] = time;
		}
		List<Time> temp = new ArrayList<Time>();
		for (int i = 0; i < times.length; i++) {
			Time time = times[i];
			for (int j = i + 1; j < times.length; j++) {
				if (Time.isTime1ThanTime2(time, times[j])) {
					Time t = new Time();
					t = time;
					time = times[j];
					times[j] = t;
				}
			}
			temp.add(time);
		}

		for (int i = 0; i < temp.size(); i++) {
			for (int j = 0; j < temp.size(); j++) {
				if (bill.getTime().get(j).equals(temp.get(i).getTime())) {
					bill2.getCardBank().add(bill.getCardBank().get(j));
					bill2.getCardnumber().add(bill.getCardnumber().get(j));
					bill2.getCardOrUser().add(bill.getCardOrUser().get(j));
					bill2.getMoney().add(bill.getMoney().get(j));
					bill2.getNickname().add(bill.getNickname().get(j));
					bill2.getPhonenumber().add(bill.getPhonenumber().get(j));
					bill2.getRecieveOrSend()
							.add(bill.getRecieveOrSend().get(j));
					bill2.getTime().add(bill.getTime().get(j));
				}
			}
		}
		return bill2;
	}
}